﻿using Hotel.BLL;
using Hotel.DAL;
using Hotel.Model;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Hotel.API.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class MemberLevelController : ControllerBase
    {
        public MemberLevelController(MemberLevelBLL memberLevelBLL)
        {
            MemberLevelBLL = memberLevelBLL;
        }
        public MemberLevelBLL MemberLevelBLL { get; }
        [HttpPost("AddMemberLevel")]
        public int AddMemberLevel(MemberLevel info)
        {
            try
            {
                return MemberLevelBLL.AddMemberLevel(info);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 获取会员等级列表
        /// </summary>
        /// <returns></returns>
        [HttpGet("AddMemberLevel")]
        public List<MemberLevel> MemberLevelsList()
        {
            try
            {
                return MemberLevelBLL.MemberLevelsList();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 获取会员列表
        /// </summary>
        /// <param name="id">会员编号</param>
        /// <param name="name">会员名称</param>
        /// <param name="levelId">等级名称</param>
        /// <returns></returns>

        [HttpGet("MemberList")]
        public List<Member> MemberList(int? id = null, string? name = "", int? levelId = null)
        {
            try
            {
                //查询所有显示的数据
                return MemberLevelBLL.MemberList(id, name, levelId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
